package mta.command.merge;

import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.ParseException;
import org.apache.commons.cli.PosixParser;

/**
 * Magento Translation Assistant
 * Copyright (c) 2009 Dmitry Nikolaev
 * Contact author: blackliteon@gmail.com
 */
public class MergeBuilderOptions {
    private String[] args;
    private CommandLine cl;

    public MergeBuilderOptions(String[] args) {
        this.args = args;
    }

    public void parse() throws ParseException {

        CommandLineParser parser = new PosixParser();
        cl = parser.parse(new MergeOptions().getOptions(), args);

        if (!cl.hasOption("f") || !cl.hasOption("t")) {
            throw new ParseException("You need to specify both 'from' and 'to' localizations");
        }
    }

    public String getFrom() {
        return cl.getOptionValue("f");
    }

    public String getTo() {
        return cl.getOptionValue("t");
    }
}
